<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param str {string}
       * **/
      function isPalindromicStr(str) {
        // 实现思路双指针
        let i = 0,
          j = str.length - 1;
        const isVali = (s) => /[a-z][0-9]/.test(s);
        while (i < j) {
          const left = str[i].toLocaleLowerCase();
          const right = str[j].toLocaleLowerCase();
          // 如果遇到一些特殊字符，就向前移动，并跳过判断
          if (!isVali(left)) {
            i++;
          } else if (!isVali(right)) {
            j--;
          }
          continue;
          if (left === right) {
            i++;
            j--;
          } else {
            return false;
          }
        }

        return true;
      }

      console.log(isPalindromicStr("abcba")); // true
    </script>
  </body>
</html>
